import VxeColumn from './VxeColumn';
import toolButtons from './ToolButtons';
import tableAction from './TableAction';
import { VxeGridInstance, BasicTableProps } from '@/components/VxeTable';
import { ref, reactive } from 'vue';
import tableFilter from '@/components/TableFilter/index.vue';
export const TableRef = ref<VxeGridInstance>();
export const FilterRef = ref<InstanceType<typeof tableFilter>>();
export default {
  FilterRef: ref<InstanceType<typeof tableFilter>>()
};

export const useConfig = (queryCall: (param) => Promise<any>) => {
  const FilterRef = ref<InstanceType<typeof tableFilter>>();
  const TableRef = ref<VxeGridInstance>();
  const defaultWhere = ref<{ JobId: string | number }>({
    JobId: 0
  });
  return {
    TableRef,
    FilterRef,
    ToolBtn: toolButtons,
    Action: tableAction,
    TableFilter: tableFilter,
    DefaultWhere: defaultWhere,
    options: reactive<BasicTableProps>({
      border: true,
      height: 'auto',
      columnConfig: {
        resizable: true
      },
      columns: VxeColumn,
      pagerConfig: {
        enabled: false
      },
      toolbarConfig: {
        enabled: true,
        export: false,
        zoom: false,
        print: false,
        refresh: false,
        custom: false
      },
      proxyConfig: {
        ajax: {
          query: () => {
            return queryCall({ ...defaultWhere });
          }
        }
      }
    })
  };
};
